package com.hongyun.sdk.common;

import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;

public class HYResponse extends HashMap<String,Object> {
    private static final long serialVersionUID = 1L;


    public static final String status = "status";
    public static final String errorCode = "errorCode";
    public static final String errorMsg = "errorMsg";

    public static HYResponse error(){
        HYResponse hyResponse = new HYResponse();
        hyResponse.put(status, HongYunCommon.HttpStatusError);
        hyResponse.put(errorCode, HYResponse.errorCode);
        hyResponse.put(errorMsg, HYResponse.errorCode);
        return hyResponse;
    }

    public static HYResponse ok(){
        HYResponse hyResponse = new HYResponse();
        hyResponse.put(status, HongYunCommon.HttpStatusOk);
        return hyResponse;
    }
    public static HYResponse error(String errorCode,String errorMsg){
        HYResponse hyResponse = new HYResponse();
        hyResponse.put(status, HongYunCommon.HttpStatusError);
        if(StringUtils.isNotBlank(errorCode)){
            hyResponse.put(errorCode, errorCode);
        }
        if(StringUtils.isNotBlank(errorMsg)){
            hyResponse.put(errorMsg, errorMsg);
        }
        return hyResponse;
    }
}
